/*********************\
* Author:Dzlua
* QQ:505544956
* Time:2017/04/15
\**********************/
#include "LuaCombo.h"

#define CObjPtr ((CComboUI*)m_cobj)

namespace DuiLib {

int LuaCombo::GetText(LuaState *L)
{
    SDTString str = CObjPtr->GetText().GetData();
    LuaHelperNS::PushTString(L, str);
    return 1;
}

void LuaCombo::SetEnabled(bool bEnable)
{
    CObjPtr->SetEnabled(bEnable);
}

UINT LuaCombo::GetTextStyle()
{
    return CObjPtr->GetTextStyle();
}

void LuaCombo::SetTextStyle(UINT uStyle)
{
    CObjPtr->SetTextStyle(uStyle);
}

DWORD LuaCombo::GetTextColor()
{
    return CObjPtr->GetTextColor();
}

void LuaCombo::SetTextColor(DWORD dwTextColor)
{
    CObjPtr->SetTextColor(dwTextColor);
}

DWORD LuaCombo::GetDisabledTextColor()
{
    return CObjPtr->GetDisabledTextColor();
}

void LuaCombo::SetDisabledTextColor(DWORD dwTextColor)
{
    CObjPtr->SetDisabledTextColor(dwTextColor);
}

void LuaCombo::SetFont(int index)
{
    CObjPtr->SetFont(index);
}

int LuaCombo::GetFont()
{
    return CObjPtr->GetFont();
}

int LuaCombo::SetTextPadding(LuaState *L)
{
    LuaStack args(L);
    RECT rc = LuaHelperNS::GetRect(args[2]);
    CObjPtr->SetTextPadding(rc);
    return 0;
}

int LuaCombo::GetTextPadding(LuaState *L)
{
    RECT rc = CObjPtr->GetTextPadding();
    LuaHelperNS::PushRect(L, rc);
    return 1;
}

bool LuaCombo::IsShowHtml()
{
    return CObjPtr->IsShowHtml();
}

void LuaCombo::SetShowHtml(bool bShowHtml)
{
    CObjPtr->SetShowHtml(bShowHtml);
}

int LuaCombo::GetDropBoxAttributeList(LuaState *L)
{
    SDTString str = CObjPtr->GetDropBoxAttributeList().GetData();
    LuaHelperNS::PushTString(L, str);
    return 1;
}

int LuaCombo::SetDropBoxAttributeList(LuaState *L)
{
    LuaStack args(L);
    SDTString str = LuaHelperNS::GetTString(args[2]);
    CObjPtr->SetDropBoxAttributeList(str.c_str());
    return 0;
}

int LuaCombo::SetDropBoxSize(LuaState *L)
{
    LuaStack args(L);
    SIZE sz = LuaHelperNS::GetSize(args[2]);
    CObjPtr->SetDropBoxSize(sz);
    return 0;
}

int LuaCombo::GetDropBoxSize(LuaState *L)
{
    SIZE sz = CObjPtr->GetDropBoxSize();
    LuaHelperNS::PushSize(L, sz);
    return 1;
}

UINT LuaCombo::GetListType()
{
    return CObjPtr->GetListType();
}

int LuaCombo::GetCurSel()
{
    return CObjPtr->GetCurSel();
}

int LuaCombo::SelectItem(LuaState *L)
{
    LuaStack args(L);
    bool bRet = false;
    int iIndex = LuaHelperNS::GetInt(args[2]);
    bool bTakeFocus = LuaHelperNS::GetBool(args[3], false);
    bRet = CObjPtr->SelectItem(iIndex, bTakeFocus);
    L->PushBoolean(bRet);
    return 1;
}

int LuaCombo::SelectMultiItem(LuaState *L)
{
    LuaStack args(L);
    bool bRet = false;
    int iIndex = LuaHelperNS::GetInt(args[2]);
    bool bTakeFocus = LuaHelperNS::GetBool(args[3], false);
    bRet = CObjPtr->SelectMultiItem(iIndex, bTakeFocus);
    L->PushBoolean(bRet);
    return 1;
}

int LuaCombo::UnSelectItem(LuaState *L)
{
    LuaStack args(L);
    bool bRet = false;
    int iIndex = LuaHelperNS::GetInt(args[2]);
    bool bTakeFocus = LuaHelperNS::GetBool(args[3], false);
    bRet = CObjPtr->UnSelectItem(iIndex, bTakeFocus);
    L->PushBoolean(bRet);
    return 1;
}

int LuaCombo::SetItemIndex(LuaState *L)
{
    LuaStack args(L);
    bool bRet = false;
    if (args[3].IsInteger()) {
        CControlUI* ctrl = (CControlUI*)LuaHelperNS::GetCObjectData(args[2]);
        bRet = CObjPtr->SetItemIndex(ctrl, args[3].GetInteger());
    }
    L->PushBoolean(bRet);
    return 1;
}

int LuaCombo::Add(LuaState *L)
{
    LuaStack args(L);
    bool bRet = false;
    CControlUI* ctrl = (CControlUI*)LuaHelperNS::GetCObjectData(args[2]);
    bRet = CObjPtr->Add(ctrl);
    L->PushBoolean(bRet);
    return 1;
}

int LuaCombo::AddAt(LuaState *L)
{
    LuaStack args(L);
    bool bRet = false;
    if (args[3].IsInteger()) {
        CControlUI* ctrl = (CControlUI*)LuaHelperNS::GetCObjectData(args[2]);
        bRet = CObjPtr->AddAt(ctrl, args[3].GetInteger());
    }
    L->PushBoolean(bRet);
    return 1;
}

int LuaCombo::Remove(LuaState *L)
{
    LuaStack args(L);
    bool bRet = false;
    CControlUI* ctrl = (CControlUI*)LuaHelperNS::GetCObjectData(args[2]);
    bRet = CObjPtr->Remove(ctrl);
    L->PushBoolean(bRet);
    return 1;
}

bool LuaCombo::RemoveAt(int iIndex)
{
    return CObjPtr->RemoveAt(iIndex);
}

void LuaCombo::RemoveAll()
{
    CObjPtr->RemoveAll();
}

bool LuaCombo::Activate()
{
    return CObjPtr->Activate();
}

int LuaCombo::GetNormalImage(LuaState *L)
{
    SDTString str = CObjPtr->GetNormalImage();
    LuaHelperNS::PushTString(L, str);
    return 1;
}

int LuaCombo::SetNormalImage(LuaState *L)
{
    LuaStack args(L);
    SDTString str = LuaHelperNS::GetTString(args[2]);
    CObjPtr->SetNormalImage(str.c_str());
    return 0;
}

int LuaCombo::GetHotImage(LuaState *L)
{
    SDTString str = CObjPtr->GetHotImage();
    LuaHelperNS::PushTString(L, str);
    return 1;
}

int LuaCombo::SetHotImage(LuaState *L)
{
    LuaStack args(L);
    SDTString str = LuaHelperNS::GetTString(args[2]);
    CObjPtr->SetHotImage(str.c_str());
    return 0;
}

int LuaCombo::GetPushedImage(LuaState *L)
{
    SDTString str = CObjPtr->GetPushedImage();
    LuaHelperNS::PushTString(L, str);
    return 1;
}

int LuaCombo::SetPushedImage(LuaState *L)
{
    LuaStack args(L);
    SDTString str = LuaHelperNS::GetTString(args[2]);
    CObjPtr->SetPushedImage(str.c_str());
    return 0;
}

int LuaCombo::GetFocusedImage(LuaState *L)
{
    SDTString str = CObjPtr->GetFocusedImage();
    LuaHelperNS::PushTString(L, str);
    return 1;
}

int LuaCombo::SetFocusedImage(LuaState *L)
{
    LuaStack args(L);
    SDTString str = LuaHelperNS::GetTString(args[2]);
    CObjPtr->SetFocusedImage(str.c_str());
    return 0;
}

int LuaCombo::GetDisabledImage(LuaState *L)
{
    SDTString str = CObjPtr->GetDisabledImage();
    LuaHelperNS::PushTString(L, str);
    return 1;
}

int LuaCombo::SetDisabledImage(LuaState *L)
{
    LuaStack args(L);
    SDTString str = LuaHelperNS::GetTString(args[2]);
    CObjPtr->SetDisabledImage(str.c_str());
    return 0;
}

bool LuaCombo::GetScrollSelect()
{
    return CObjPtr->GetScrollSelect();
}

void LuaCombo::SetScrollSelect(bool bScrollSelect)
{
    CObjPtr->SetScrollSelect(bScrollSelect);
}

void LuaCombo::SetItemFont(int index)
{
    CObjPtr->SetItemFont(index);
}

void LuaCombo::SetItemTextStyle(UINT uStyle)
{
    CObjPtr->SetItemTextStyle(uStyle);
}

int LuaCombo::SetItemTextPadding(LuaState *L)
{
    LuaStack args(L);
    RECT rc = LuaHelperNS::GetRect(args[2]);
    CObjPtr->SetItemTextPadding(rc);
    return 0;
}

int LuaCombo::GetItemTextPadding(LuaState *L)
{
    RECT rc = CObjPtr->GetItemTextPadding();
    LuaHelperNS::PushRect(L, rc);
    return 1;
}

DWORD LuaCombo::GetItemTextColor()
{
    return CObjPtr->GetItemTextColor();
}

void LuaCombo::SetItemTextColor(DWORD dwTextColor)
{
    CObjPtr->SetItemTextColor(dwTextColor);
}

DWORD LuaCombo::GetItemBkColor()
{
    return CObjPtr->GetItemBkColor();
}

void LuaCombo::SetItemBkColor(DWORD dwTextColor)
{
    CObjPtr->SetItemBkColor(dwTextColor);
}

int LuaCombo::GetItemBkImage(LuaState *L)
{
    SDTString str = CObjPtr->GetItemBkImage();
    LuaHelperNS::PushTString(L, str);
    return 1;
}

int LuaCombo::SetItemBkImage(LuaState *L)
{
    LuaStack args(L);
    SDTString str = LuaHelperNS::GetTString(args[2]);
    CObjPtr->SetItemBkImage(str.c_str());
    return 0;
}

bool LuaCombo::IsAlternateBk()
{
    return CObjPtr->IsAlternateBk();
}

void LuaCombo::SetAlternateBk(bool bAlternateBk)
{
    CObjPtr->SetAlternateBk(bAlternateBk);
}

DWORD LuaCombo::GetSelectedItemTextColor()
{
    return CObjPtr->GetSelectedItemTextColor();
}

void LuaCombo::SetSelectedItemTextColor(DWORD dwTextColor)
{
    CObjPtr->SetSelectedItemTextColor(dwTextColor);
}

DWORD LuaCombo::GetSelectedItemBkColor()
{
    return CObjPtr->GetSelectedItemBkColor();
}

void LuaCombo::SetSelectedItemBkColor(DWORD dwBkColor)
{
    CObjPtr->SetSelectedItemBkColor(dwBkColor);
}

int LuaCombo::GetSelectedItemImage(LuaState *L)
{
    SDTString str = CObjPtr->GetSelectedItemImage();
    LuaHelperNS::PushTString(L, str);
    return 1;
}

int LuaCombo::SetSelectedItemImage(LuaState *L)
{
    LuaStack args(L);
    SDTString str = LuaHelperNS::GetTString(args[2]);
    CObjPtr->SetSelectedItemImage(str.c_str());
    return 0;
}

void LuaCombo::SetHotItemTextColor(DWORD dwTextColor)
{
    CObjPtr->SetHotItemTextColor(dwTextColor);
}

DWORD LuaCombo::GetHotItemTextColor()
{
    return CObjPtr->GetHotItemTextColor();
}

void LuaCombo::SetHotItemBkColor(DWORD dwTextColor)
{
    CObjPtr->SetHotItemBkColor(dwTextColor);
}

DWORD LuaCombo::GetHotItemBkColor()
{
    return CObjPtr->GetHotItemBkColor();
}

int LuaCombo::GetHotItemImage(LuaState *L)
{
    SDTString str = CObjPtr->GetHotItemImage();
    LuaHelperNS::PushTString(L, str);
    return 1;
}

int LuaCombo::SetHotItemImage(LuaState *L)
{
    LuaStack args(L);
    SDTString str = LuaHelperNS::GetTString(args[2]);
    CObjPtr->SetHotItemImage(str.c_str());
    return 0;
}

void LuaCombo::SetDisabledItemTextColor(DWORD dwTextColor)
{
    CObjPtr->SetDisabledItemTextColor(dwTextColor);
}

DWORD LuaCombo::GetDisabledItemTextColor()
{
    return CObjPtr->GetDisabledItemTextColor();
}

void LuaCombo::SetDisabledItemBkColor(DWORD dwTextColor)
{
    CObjPtr->SetDisabledItemBkColor(dwTextColor);
}

DWORD LuaCombo::GetDisabledItemBkColor()
{
    return CObjPtr->GetDisabledItemBkColor();
}

int LuaCombo::GetDisabledItemImage(LuaState *L)
{
    SDTString str = CObjPtr->GetDisabledItemImage();
    LuaHelperNS::PushTString(L, str);
    return 1;
}

int LuaCombo::SetDisabledItemImage(LuaState *L)
{
    LuaStack args(L);
    SDTString str = LuaHelperNS::GetTString(args[2]);
    CObjPtr->SetDisabledItemImage(str.c_str());
    return 0;
}

void LuaCombo::SetItemLineColor(DWORD dwTextColor)
{
    CObjPtr->SetItemLineColor(dwTextColor);
}

DWORD LuaCombo::GetItemLineColor()
{
    return CObjPtr->GetItemLineColor();
}

bool LuaCombo::IsItemShowHtml()
{
    return CObjPtr->IsItemShowHtml();
}

void LuaCombo::SetItemShowHtml(bool bShowHtml)
{
    CObjPtr->SetItemShowHtml();
}

int LuaCombo::EstimateSize(LuaState *L)
{
    LuaStack args(L);
    SIZE szAvailable = LuaHelperNS::GetSize(args[2]);
    SIZE sz = CObjPtr->EstimateSize(szAvailable);
    LuaHelperNS::PushSize(L, sz);
    return 1;
}

int LuaCombo::SetPos(LuaState *L)
{
    LuaStack args(L);
    RECT rc = LuaHelperNS::GetRect(args[2]);
    bool bNeedInvalidate = LuaHelperNS::GetBool(args[3], true);
    CObjPtr->SetPos(rc, bNeedInvalidate);
    return 0;
}

int LuaCombo::Move(LuaState *L)
{
    LuaStack args(L);
    SIZE sz = LuaHelperNS::GetSize(args[2]);
    bool bNeedInvalidate = LuaHelperNS::GetBool(args[3], true);
    CObjPtr->Move(sz, bNeedInvalidate);
    return 0;
}

SDLUA_BEGIN_REGISTER(LuaCombo, Combo, Container)
    SDLUA_REGISTER_FUN_LUA(LuaCombo, GetText, GetText)
    SDLUA_REGISTER_FUN_CPP(LuaCombo, SetEnabled, SetEnabled)

    SDLUA_REGISTER_FUN_CPP(LuaCombo, SetTextStyle, SetTextStyle)
    SDLUA_REGISTER_FUN_CPP(LuaCombo, GetTextStyle, GetTextStyle)
    SDLUA_REGISTER_FUN_CPP(LuaCombo, SetTextColor, SetTextColor)
    SDLUA_REGISTER_FUN_CPP(LuaCombo, GetTextColor, GetTextColor)
    SDLUA_REGISTER_FUN_CPP(LuaCombo, SetDisabledTextColor, SetDisabledTextColor)
    SDLUA_REGISTER_FUN_CPP(LuaCombo, GetDisabledTextColor, GetDisabledTextColor)
    SDLUA_REGISTER_FUN_CPP(LuaCombo, SetFont, SetFont)
    SDLUA_REGISTER_FUN_CPP(LuaCombo, GetFont, GetFont)
    SDLUA_REGISTER_FUN_LUA(LuaCombo, GetTextPadding, GetTextPadding)
    SDLUA_REGISTER_FUN_LUA(LuaCombo, SetTextPadding, SetTextPadding)
    SDLUA_REGISTER_FUN_CPP(LuaCombo, IsShowHtml, IsShowHtml)
    SDLUA_REGISTER_FUN_CPP(LuaCombo, SetShowHtml, SetShowHtml)

    SDLUA_REGISTER_FUN_LUA(LuaCombo, GetDropBoxAttributeList, GetDropBoxAttributeList)
    SDLUA_REGISTER_FUN_LUA(LuaCombo, SetDropBoxAttributeList, SetDropBoxAttributeList)
    SDLUA_REGISTER_FUN_LUA(LuaCombo, GetDropBoxSize, GetDropBoxSize)
    SDLUA_REGISTER_FUN_LUA(LuaCombo, SetDropBoxSize, SetDropBoxSize)

    SDLUA_REGISTER_FUN_CPP(LuaCombo, GetListType, GetListType)
    SDLUA_REGISTER_FUN_CPP(LuaCombo, GetCurSel, GetCurSel)
    SDLUA_REGISTER_FUN_LUA(LuaCombo, SelectItem, SelectItem)
    SDLUA_REGISTER_FUN_LUA(LuaCombo, SelectMultiItem, SelectMultiItem)
    SDLUA_REGISTER_FUN_LUA(LuaCombo, UnSelectItem, UnSelectItem)
    SDLUA_REGISTER_FUN_LUA(LuaCombo, SetItemIndex, SetItemIndex)

    SDLUA_REGISTER_FUN_LUA(LuaCombo, Add, Add)
    SDLUA_REGISTER_FUN_LUA(LuaCombo, AddAt, AddAt)
    SDLUA_REGISTER_FUN_LUA(LuaCombo, Remove, Remove)
    SDLUA_REGISTER_FUN_CPP(LuaCombo, RemoveAt, RemoveAt)
    SDLUA_REGISTER_FUN_CPP(LuaCombo, RemoveAll, RemoveAll)

    SDLUA_REGISTER_FUN_CPP(LuaCombo, Activate, Activate)
    
    SDLUA_REGISTER_FUN_LUA(LuaCombo, GetNormalImage, GetNormalImage)
    SDLUA_REGISTER_FUN_LUA(LuaCombo, SetNormalImage, SetNormalImage)
    SDLUA_REGISTER_FUN_LUA(LuaCombo, GetHotImage, GetHotImage)
    SDLUA_REGISTER_FUN_LUA(LuaCombo, SetHotImage, SetHotImage)
    SDLUA_REGISTER_FUN_LUA(LuaCombo, GetPushedImage, GetPushedImage)
    SDLUA_REGISTER_FUN_LUA(LuaCombo, SetPushedImage, SetPushedImage)
    SDLUA_REGISTER_FUN_LUA(LuaCombo, GetFocusedImage, GetFocusedImage)
    SDLUA_REGISTER_FUN_LUA(LuaCombo, SetFocusedImage, SetFocusedImage)
    SDLUA_REGISTER_FUN_LUA(LuaCombo, GetDisabledImage, GetDisabledImage)
    SDLUA_REGISTER_FUN_LUA(LuaCombo, SetDisabledImage, SetDisabledImage)
    
    SDLUA_REGISTER_FUN_CPP(LuaCombo, GetScrollSelect, GetScrollSelect)
    SDLUA_REGISTER_FUN_CPP(LuaCombo, SetScrollSelect, SetScrollSelect)

    SDLUA_REGISTER_FUN_CPP(LuaCombo, SetItemFont, SetItemFont)
    SDLUA_REGISTER_FUN_CPP(LuaCombo, SetItemTextStyle, SetItemTextStyle)
    SDLUA_REGISTER_FUN_LUA(LuaCombo, GetItemTextPadding, GetItemTextPadding)
    SDLUA_REGISTER_FUN_LUA(LuaCombo, SetItemTextPadding, SetItemTextPadding)
    SDLUA_REGISTER_FUN_CPP(LuaCombo, GetItemTextColor, GetItemTextColor)
    SDLUA_REGISTER_FUN_CPP(LuaCombo, SetItemTextColor, SetItemTextColor)
    SDLUA_REGISTER_FUN_CPP(LuaCombo, GetItemBkColor, GetItemBkColor)
    SDLUA_REGISTER_FUN_CPP(LuaCombo, SetItemBkColor, SetItemBkColor)
    SDLUA_REGISTER_FUN_LUA(LuaCombo, GetItemBkImage, GetItemBkImage)
    SDLUA_REGISTER_FUN_LUA(LuaCombo, SetItemBkImage, SetItemBkImage)
    SDLUA_REGISTER_FUN_CPP(LuaCombo, IsAlternateBk, IsAlternateBk)
    SDLUA_REGISTER_FUN_CPP(LuaCombo, SetAlternateBk, SetAlternateBk)
    SDLUA_REGISTER_FUN_CPP(LuaCombo, GetSelectedItemTextColor, GetSelectedItemTextColor)
    SDLUA_REGISTER_FUN_CPP(LuaCombo, SetSelectedItemTextColor, SetSelectedItemTextColor)
    SDLUA_REGISTER_FUN_CPP(LuaCombo, GetSelectedItemBkColor, GetSelectedItemBkColor)
    SDLUA_REGISTER_FUN_CPP(LuaCombo, SetSelectedItemBkColor, SetSelectedItemBkColor)
    SDLUA_REGISTER_FUN_LUA(LuaCombo, GetSelectedItemImage, GetSelectedItemImage)
    SDLUA_REGISTER_FUN_LUA(LuaCombo, SetSelectedItemImage, SetSelectedItemImage)
    SDLUA_REGISTER_FUN_CPP(LuaCombo, GetHotItemTextColor, GetHotItemTextColor)
    SDLUA_REGISTER_FUN_CPP(LuaCombo, SetHotItemTextColor, SetHotItemTextColor)
    SDLUA_REGISTER_FUN_CPP(LuaCombo, GetHotItemBkColor, GetHotItemBkColor)
    SDLUA_REGISTER_FUN_CPP(LuaCombo, SetHotItemBkColor, SetHotItemBkColor)
    SDLUA_REGISTER_FUN_LUA(LuaCombo, GetHotItemImage, GetHotItemImage)
    SDLUA_REGISTER_FUN_LUA(LuaCombo, SetHotItemImage, SetHotItemImage)
    SDLUA_REGISTER_FUN_CPP(LuaCombo, GetDisabledItemTextColor, GetDisabledItemTextColor)
    SDLUA_REGISTER_FUN_CPP(LuaCombo, SetDisabledItemTextColor, SetDisabledItemTextColor)
    SDLUA_REGISTER_FUN_CPP(LuaCombo, GetDisabledItemBkColor, GetDisabledItemBkColor)
    SDLUA_REGISTER_FUN_CPP(LuaCombo, SetDisabledItemBkColor, SetDisabledItemBkColor)
    SDLUA_REGISTER_FUN_LUA(LuaCombo, GetDisabledItemImage, GetDisabledItemImage)
    SDLUA_REGISTER_FUN_LUA(LuaCombo, SetDisabledItemImage, SetDisabledItemImage)
    SDLUA_REGISTER_FUN_CPP(LuaCombo, GetItemLineColor, GetItemLineColor)
    SDLUA_REGISTER_FUN_CPP(LuaCombo, SetItemLineColor, SetItemLineColor)
    SDLUA_REGISTER_FUN_CPP(LuaCombo, IsItemShowHtml, IsItemShowHtml)
    SDLUA_REGISTER_FUN_CPP(LuaCombo, SetItemShowHtml, SetItemShowHtml)

    SDLUA_REGISTER_FUN_LUA(LuaCombo, EstimateSize, EstimateSize)
    SDLUA_REGISTER_FUN_LUA(LuaCombo, SetPos, SetPos)
    SDLUA_REGISTER_FUN_LUA(LuaCombo, Move, Move)

SDLUA_END_REGISTER

SDLUA_BEGIN_UNREGISTER(LuaCombo, Combo)
SDLUA_END_UNREGISTER(Combo)

}

#undef CObjPtr